//
//  WhoViewController.m
//  ALittleReminder
//
//  Created by Arsh Bhullar on 11-11-03.

#import "WhoViewController.h"
#import "MedicalInfo.h"
#import "WhoamIAccount.h"

@implementation WhoViewController


-(IBAction)onClickClose:(id)sender{
    
    
    [self dismissModalViewControllerAnimated:YES];
    
}


-(IBAction)onClickEdit:(id)sender{
    WhoamIAccount *openView = [[WhoamIAccount alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:openView animated:YES];
}



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [paths objectAtIndex: 0];
    NSString *docFile = [docDir stringByAppendingPathComponent: @"myInfo.txt"];
    
    NSString *textfromfile = [NSString stringWithContentsOfFile:docFile encoding:NSStringEncodingConversionAllowLossy error:nil];
    
    NSArray *info = [textfromfile componentsSeparatedByString:@"-"];
    
    name.text = [info objectAtIndex:0];
    address.text = [info objectAtIndex:1];
    city.text = [info objectAtIndex:2];
    phone.text = [info objectAtIndex:3];
    medical.text = [info objectAtIndex:4];
    /*UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"images.png"]];
    image.frame = CGRectMake(0, 0, 125, 125);
    image.center = CGPointMake(150, 100);
    [self.view addSubview:image];*/
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)onMedicalInfoButton:(id)sender {
    MedicalInfo *openView = [[MedicalInfo alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:openView animated:YES];
}

@end
